package com.java.module.fire.controller.admin;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.java.common.lang.annotation.Log;
import com.java.common.lang.domain.AjaxResult;
import com.java.common.lang.enums.BusinessTypeEnum;
import com.java.common.utils.WebKit;
import com.java.module.fire.domain.Project;
import com.java.module.fire.service.IProjectService;
import com.java.common.utils.poi.ExcelUtil;
import com.java.common.lang.domain.page.TableDataInfo;

/**
 * 匹配信息Controller
 * 
 * @author Administrator
 * @date 2025-02-10
 */
@RestController("AdminProjectController")
@RequestMapping("/fire/project")
public class ProjectController {
    @Autowired
    private IProjectService projectService;

    /**
     * 查询匹配信息列表
     */
    @PreAuthorize("@ss.hasPermi('fire:project:list')")
    @GetMapping("/list")
    public TableDataInfo list(Project project) {
        WebKit.startPage();
        List<Project> list = projectService.selectProjectList(project);
        return WebKit.getDataTable(list);
    }

    /**
     * 导出匹配信息列表
     */
    @PreAuthorize("@ss.hasPermi('fire:project:export')")
    @Log(title = "匹配信息", businessType = BusinessTypeEnum.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Project project) {
        List<Project> list = projectService.selectProjectList(project);
        ExcelUtil<Project> util = new ExcelUtil<Project>(Project.class);
        return util.exportExcel(list, "project");
    }

    /**
     * 获取匹配信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('fire:project:query')")
    @GetMapping(value = "/{projectId}")
    public AjaxResult getInfo(@PathVariable("projectId") Long projectId) {
        return AjaxResult.success(projectService.selectProjectById(projectId));
    }

    /**
     * 新增匹配信息
     */
    @PreAuthorize("@ss.hasPermi('fire:project:add')")
    @Log(title = "匹配信息", businessType = BusinessTypeEnum.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Project project) {
        return WebKit.toAjax(projectService.insertProject(project));
    }

    /**
     * 修改匹配信息
     */
    @PreAuthorize("@ss.hasPermi('fire:project:edit')")
    @Log(title = "匹配信息", businessType = BusinessTypeEnum.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Project project) {
        return WebKit.toAjax(projectService.updateProject(project));
    }

    /**
     * 删除匹配信息
     */
    @PreAuthorize("@ss.hasPermi('fire:project:remove')")
    @Log(title = "匹配信息", businessType = BusinessTypeEnum.DELETE)
	@DeleteMapping("/{projectIds}")
    public AjaxResult remove(@PathVariable Long[] projectIds) {
        return WebKit.toAjax(projectService.deleteProjectByIds(projectIds));
    }
}
